package org.example.product.controller;

import java.math.BigDecimal;
import java.util.List;

import org.example.core.utils.PageUtils;
import org.example.core.utils.R;
import org.example.product.entity.SkuInfoEntity;
import org.example.product.service.SkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;




/**
 * @author 小杰_cc
 * @version 1.0
 */
@RestController
@RequestMapping("/pms/backend/skuInfo")
public class SkuInfoController {
    @Autowired
    private SkuInfoService skuInfoService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R<?> list(@RequestParam(required = false) String skuTitle,
                     @RequestParam(required = false) Long categoryId,
                     @RequestParam(required = false) Long brandId,
                     @RequestParam(required = false) BigDecimal priceMax,
                     @RequestParam(required = false) BigDecimal priceMin,
                     @RequestParam(defaultValue = "1") Integer pageNum,
                     @RequestParam(defaultValue = "10") Integer pageSize){
        PageUtils pageUtils = skuInfoService.querySkuInfoList(skuTitle,categoryId,brandId,priceMax,priceMin,pageNum,pageSize);
        return R.ok(pageUtils);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{skuId}")
    public R<?> info(@PathVariable("skuId") Long skuId){

        return null;
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R<?> save(@RequestBody SkuInfoEntity skuInfo){

        return null;
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R<?> update(@RequestBody SkuInfoEntity skuInfo){

        return null;
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R<?> delete(@RequestBody Long[] skuIds){

        return null;
    }

    /**
     * 查询秒杀商品信息
     */
    @PostMapping("/seckillSku")
    public R<?> getSkuListByIds(@RequestBody List<Long> skuIds){
        return R.ok(skuInfoService.queryCartSkus(skuIds));
    }
}
